package com.promote.algorithm;


/**
 * @ClassName Fibonacci
 * Description 斐波那契数列---力扣
 * @Author LiZiHao
 * Date 2021/11/16 10:44
 * @Version 1.0
 **/
public class Fibonacci {


    public static int fib(int n) {
        //动态规划
        int a = 0, b = 1, sum;
        for(int i = 0; i < n; i++){
            sum = (a + b) % 1000000007;
            a = b;
            b = sum;
        }
        return a;
    }

    public static void main(String[] args) {
        int n = 10;

        int fib = fib(n);

        System.out.println(fib);

    }
}
